The present invention is generally related to the preservation of attributes of persistent objects when modifications are made thereto, and more specifically, to preserving attributes of the objects when a file including the objects is opened within an environment different than that in which the file was originally created.
As a general rule, new versions of software add functions and attributes to objects in the software that were not found in previous versions. Because of differences between successive versions of a program related to implementing new functionality, problems can arise when a document or file created under a newer version of a software program is subsequently opened, executed, and/or revised, and then saved by an older version of the software. For example, Microsoft Corporation""s WORD(trademark) version 7 word processing program includes a feature in which Internet (or intranet) links are automatically recognized so that the corresponding site/page is readily accessed in a browser program activated when the link is selected (i.e., by double clicking a mouse or other pointing device while the cursor controlled by the device is over the link). To clearly differentiate such links from normal text, they are typically displayed using a blue font. Any document that includes such a link, when opened, in an earlier version of the WORD(trademark) word processing program, will also display the link in the blue font, but the older version of WORD(trademark) will not provide the underlying hypertext link to the site referenced by the link and is unable to automatically cause a browser to open up the page referenced by the link. Moreover, if the document that originally included the link was created in version 7 of the WORD(trademark) word processing program is opened and saved in an earlier version of the program, a hypertext link will no longer be associated with blue font text that references the site if the saved document is subsequently opened in version 7 of the word processing program. In other words, since the older version of the word processing program is not equipped to recognize the hypertext association originally included in the document, the software does not preserve the hypertext association in the document when saving it. The new or added functionality associated with objects in the document is thus lost as a result of the document being opened and saved by the earlier version of the word processing program.
A related problem arises when a hypertext markup language (HTML) document created in a conventional text editor is subsequently imported into, for example, Microsoft Corporation""s FRONTPAGE(trademark) software application, which includes an HTML editor. This HTML editor is of the xe2x80x9cwhat you see is what you getxe2x80x9d (WYSIWYG) type, which greatly facilitates developing the desired look and feel of a web page compared to simple text editors. (Notexe2x80x94the discussion of HTML documents that follows herein and in the claims is intended to encompass extended markup language (XML) documents as well.) Earlier versions of FRONTPAGE(trademark) have not made any attempt to preserve the stylistic formatting of an HTML document applied by the user in a text editor, when the document was opened within the HTML editor and then saved, but have simply applied a generally predefined style that is hard coded into the HTML editor, when saving any HTML document. Thus, the original formatting layout, indent levels, whitespace, and other stylistic attributes of objects established by a user in a document when it was originally created and saved with a text editor, were lost by opening the document to make any change within the FRONTPAGE(trademark) HTML editor environment. Simply saving the document after it was opened in the FRONTPAGE(trademark) editor caused these stylistic and layout attributes to be lost.
One of the reasons that the formatting style of an HTML document has not previously been preserved under these circumstances is that an HTML editor usually transforms such a document into a substantially different representation internally, because the internal representation more effectively models how a web browser will display a web page defined by an HTML document. Particularly after changes to an imported HTML document have been made in an HTML editor, it becomes substantially more difficult to regenerate format and style (whitespace) of the original HTML document. However, people who create HTML documents often have strong opinions about retaining the style that they have applied to these documents. Users often believe that their style lends an HTML document readability; further, they may desire to retain a consistent look to all of the HTML documents that they create, based on their preferences. It is not surprising that many users of prior art HTML editing programs such as earlier versions of FRONTPAGE(trademark) have been unhappy about the loss of their preferred formatting style and layout in an HTML document when the document was opened in the HTML editor and then saved.
Of even greater concern than possible loss of a preferred formatting is that changes made by previous versions of FRONTPAGE(trademark) to the whitespace and layout of an HTML document imported into the HTML editor can actually break the functionality of scripts and unknown tags on a page. The result is that simply by opening and re-saving the page (or by editing it in the xe2x80x9cwysiwygxe2x80x9d view of the program), the page is so changed that scripts may not function and the formatting and layout of page""s displayed content may possibly be changed.
Ideally, an HTML document created in one environment that is imported into another environment, such as an HTML editor, should preserve the document""s original formatting, including both the text and layout style (whitespace) around objects, as much as possible. Importing an HTML document into an editor should not cause any loss of functionality or loss of formatting in tables. Furthermore, the HTML editor should determine the formatting style employed in an imported HTML document created in a different environment so that the style may be applied to changes made to the document within the HTML editor and to newly added objects. Clearly, if a user has simply opened an HTML document within the HTML editor and saved it without making any changes, additions, or deletions, the exact formatting style and text of the original document should be retained. It would also be desirable to enable the user to compare the original version of the HTML document with the version that is saved, after changes, deletions, or additions have been made by the HTML editor. This comparison might be made using any of various types of document comparison tools available from other sources, so that the user can see the changes made as a result of editing the HTML document.
The prior art does not provide a fully satisfactory solution to these problems. Macromedia""s DREAMWEAVER(trademark) software includes an HTML editor that preserves much of the whitespace in an imported HTML document that has been opened and then saved. However, once a structure or region in an imported HTML document is edited in the DREAMWEAVER HTML editor, the whitespace is reformatted to conform to an internally predetermined style that is part of the software program. Furthermore, if text is added to an imported HTML document open in the DREAMWEAVER(trademark) HTML editor, the indent level of the existing surrounding text is not applied to the newly added text. When a copy/paste editing function is implemented in an open document, i.e., when formatted text is copied and then pasted into a different part of an HTML document, all surrounding whitespace related to the copied text is lost in the region in which the text is pasted.
Another prior art editor, which is used for more general program development applicable to a multi-tier architecture, appears in Microsoft Corporation""s VISUAL INTERDEV(trademark), version 6.0 software. This editor attempts to preserve certain attributes of specific objects in an imported text file. Whitespace in a text file that is opened in the editor and saved without changes is preserved; but, if changes are made in the file, tags may be modified, attribute value case is not preserved, attribute ordering is not preserved, and whitespace is not preserved. In addition, whitespace surrounding plain text is not preserved. Entities that may appear in the text, e.g., representation of printable characters in a form such as xe2x80x9cand#97,xe2x80x9d are generated when needed, but only in one preferred form, not necessarily in the form employed by the user in an imported file created in a different environment. It would be preferable to preserve the form used in an imported text file and to employ the same type or form for representing any new entities added to a document or file.
As will be apparent from the initial discussion relating to the problems that arise due to differences in attributes employed in different versions of a word processing program, these problems are not limited to imported HTML documents opened in an HTML editor. More generally, these problems can arise when files that include objects having associated attributes, in one system are opened in another system or software environment. For example, in a programming environment, the class of an object should persist, even though class descriptions change in a different environment/version of the programming language. This point is illustrated by the following. Assume that a software system includes an object named xe2x80x9cCEmployee.xe2x80x9d This object has the following class definition:
After the software system enables input data on employees to be printed, it is usually desirable to enable the data to be saved for future use. When making the CEmployee object persistent, most software systems use an algorithm like:
The software will invoke these output routines repeatedly, once for each employee object to be stored, resulting in an output stream that looks like:
John*Doe*123456789*FRONTPAGE+Jane*Smith*234567890*FRONTPAGE
or:
FirstName*John*LastName*Doe*SSN*123456789*Department*
FRONTPAGE+FirstName*Jane*LastName*Smith*SSN*234567890*
Department*FRONTPAGE
where * represents a marker the software recognizes as separating the data values and + represents a marker the software recognizes as separating each object.
The software reads the code with an algorithm such as:
However, a later version of the software may extend the CEmployee class by adding the attribute xe2x80x9cManagerxe2x80x9d:
The above definitions of Store and Read will also be extended in the new version of the software in a way that will be apparent to those of ordinary skill in the art. After use with the new version of the software system, the persistent data will appear as:
John*Doe*123456789*FRONTPAGE*JackSprat+Jane*Smith*234567890*FRONTPAGE+CharlesNoman
or
FirstName*John*LastName*Doe*SSN*123456789*Department*
FRONTPAGE*Manager*JackSprat+FirstName*Jane*LastName*Smith*
SSN*234567890*Department*FRONTPAGE*Manager*CharlesNoman
But, when these data are presented to the old software system, which is not programmed to deal with the new Manager data attribute, the old software system will either fail, because it expects the + object separator, or it will skip over the unexpected data attributes to the + separator. In any case, the Manager data attribute will be discarded and thus will not be available when the data are again loaded into the new version of the software in which Manager and the * separator are understood.
From the preceding discussion, it will be apparent that the prior art does not provide a complete solution to preserving formatting, layout, and attributes in a document within different environments or systems. Accordingly, there is a need for a method that addresses this problem, by preserving formatting and other attributes of objects in a document or other file that is created in one environment, but opened and saved in a different environment. Also, when changes are made to such a document in the different environment, it is preferable that these changes substantially conform to a style that is derived from that of the original document or file.
In accord with the present invention, a method is defined for preserving attributes of original objects in a file when the file is opened and saved in a different environment than that in which the file was originally created. The method includes the step of defining a set of preservation rules corresponding to how various objects and attributes associated with those objects are to be preserved in the different environment. Upon opening the file in the different environment, the file is parsed to identify any original objects in the document, and data corresponding to the original objects and any attributes corresponding to those original elements are temporarily stored in the different environment. A user is then enabled to edit the file, as desired. During the editing process, new objects and associated attributes may be added to the file, and original objects and attributes may be changed or removed. The object and attribute content of the edited file is then written to a revised file that includes all of the remaining original objects and their associated attributes, as well as any new objects and attributes that have been added, and the attributes of the original objects are preserved based on preservation rules corresponding to those original objects and their attributes.
Objects in the file may include text entries having whitespace attributes. A whitespace attribute that is associated with a text entry is preserved in the revised file unless changed while the file is open in the different environment. Also, objects in the file may include tag entries having whitespace attributes, and a whitespace attribute associated with a tag entry is preserved in the copy unless changed while the file is open in the different environment. Objects in any class that is unknown in the different environment are preserved in the copy and are ignored in the different environment, but are merged with known objects when the file is written.
A different internal representation of the attributes associated with objects in the file is employed in the revised file as compared with the internal representation of the file in the environment in which it was originally created. Attributes corresponding to original objects in the file are determined when the file is opened. These attributes are then associated with any related new objects that are added to the file while the file is open, so that attributes of the related new objects are consistent with attributes of the original objects.
The method is especially well-suited for use in programming environments in general, and for use in Web design environments in particular. For example, the present invention enables a user to open and display an HTML or other markup-language document created in an original environment that differs from the environment provided by the present invention using stylistic formatting preferences of the user, such that the stylistic format of the document is preserved when thus opened and displayed. The user can then edit and save the document. Upon saving the document, the stylistic format of the original portions of the document are preserved to the extent possible (i.e., to the extent not changed by the editing). In addition, the user may choose to have the stylistic format of the original portions of the document applied to any new objects that are added to the document that have attributes related to the original portions. For instance, the new objects may be automatically indented and new lines may be added when the document is saved, based on an indentation level of related HTML tags that were in original portions of the document.
In addition, the method is able to preserve omitted tags in the HTML document when omission of such tags will not effect rendering of the document. In general, tags that are omitted in an original document will still be omitted in a revised document, unless the document has been edited in a manner that makes the omitted tag significant. In these instances, the omitted tag is explicitly added to the revised document when it is saved, to ensure that the document is properly rendered.
Another aspect of the present invention is directed to a system that includes a memory in which data and machine instructions are stored, a display on which graphics and text are presented to a user, a processor that is coupled to the memory and executes the machine instructions, and a user input device adapted to enable the user to input data and to control the processor. When executed by the processor, the machine instructions cause the processor to implement functions that are generally consistent with the steps of the method set forth above.
A computer-readable medium having computer-executable instructions for performing the steps of the method is yet another aspect of the present invention.